TypInfo, gnugettext, gnugettextDx,\r
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,\r
StdCtrls, ExtCtrls, ComCtrls, Buttons,\r
- Common;\r
+ Common, delphi;\r
\r
type\r
TfrmOptions = class(TForm)\r
\r
{$R *.DFM}\r
\r
+// returns "BottomRight" of Controls rect\r
+\r
+function SetCaption(Control: TControl; const ACaption: string): TPoint;\r
+var\r
+ s: TStaticText;\r
+ auto, info: PPropInfo;\r
+ font: TFont;\r
+ parentf: Boolean;\r
+begin\r
+ Result := Control.BoundsRect.BottomRight;\r
+\r
+ info := GetPropInfo(Control, 'Caption');\r
+ if (info = nil) then Exit;\r
+\r
+ SetStrProp(Control, 'Caption', ACaption);\r
+\r
+ auto := GetPropInfo(Control, 'AutoSize');\r
+ if (auto <> nil) then\r
+ begin\r
+ SetOrdProp(Control, auto, Integer(True));\r
+ Result := Control.BoundsRect.BottomRight;\r
+ Exit;\r
+ end;\r
+\r
+ info := GetPropInfo(Control, 'Font');\r
+ if (info = nil) then Exit;\r
+\r
+ font := Pointer(GetObjectProp(Control, info));\r
+\r
+ info := GetPropInfo(Control, 'ParentFont');\r
+ if (info <> nil) then\r
+ parentf := Boolean(GetOrdProp(Control, info)) else\r
+ parentf := False;\r
+\r
+// Controls with Caption but without AutoSize\r
+// TCheckBox, TRadioButton\r
+\r
+ s := TStaticText.Create(Control.Owner);\r
+ try\r
+ s.Font := font;\r
+ s.ParentFont := parentf;\r
+ s.Visible := False;\r
+ s.Parent := Control.Parent;\r
+ s.BoundsRect := Control.BoundsRect;\r
+ s.AutoSize := True;\r
+ s.Caption := ACaption;\r
+ Control.Width := 18 + s.Width;\r
+ if (Control.Height < s.Height) then\r
+ Control.Height := s.Height;\r
+ Result := Control.BoundsRect.BottomRight;\r
+ finally\r
+ s.Free;\r
+ end;\r
+end;\r
+\r
+{ TfrmOptions }\r
+\r
constructor TfrmOptions.Create(AOwner: TComponent); // override;\r
begin\r
inherited Create(AOwner);\r
wc: TControl;\r
o: POption;\r
chb: TCheckBox;\r
- xy: TPoint;\r
+ xy, _xy: TPoint;\r
xmax: Integer;\r
lb: TLabel;\r
begin\r
+ if (AList = nil) then Exit;\r
+ \r
FOpts := AList;\r
\r
xy.x := 0;\r
InsertComponent(chb);\r
\r
chb.ParentFont := False;\r
- chb.Font := Main.frmMain.stbMain.Font;\r
+ chb.Font := pnOptions.Font;\r
chb.Left := 8;\r
chb.Top := xy.y;\r
- chb.Caption := dgettext('Options', o.Hint);\r
+ _xy := SetCaption(chb, dgettext(GPSBabel_Domain, o.Hint));\r
chb.Alignment := taRightJustify;\r
chb.Checked := False;\r
chb.Parent := pnOptions;\r
\r
chb.Hint := SysUtils.Format(_('Short "%s"'), [o.name]);\r
chb.ShowHint := True;\r
- chb.Width := 21 + Trunc(FCanvas.TextWidth(chb.Caption) * 1.25);\r
\r
xy.y := xy.y + chb.Height + 8;\r
if (o.otype <> 4) then\r
if (chb.Width > xy.x) then xy.x := chb.Width;\r
if (chb.Width > xy.x) then\r
xmax := chb.Width;\r
+\r
+ if (o.otype = 4) and (o.def <> nil) and (atoi(o.def) <> 0) then\r
+ begin\r
+ chb.AllowGrayed := True;\r
+ chb.State := cbGrayed;\r
+ end;\r
end;\r
\r
xy.y := 8;\r
end;\r
if (o.edit <> nil) then\r
o.edit.Enabled := False;\r
- xy.y := xy.y + chb.Height + 8;\r
+ xy.y := xy.y + o.chb.Height + 8;\r
end;\r
\r
xy.X := 0;\r
for i := 0 to FOpts.Count - 1 do\r
begin\r
o := Pointer(FOpts.Objects[i]);\r
- if (o.chb = nil) or not(o.chb.Checked) then Continue;\r
+ if (o.chb = nil) then Continue;\r
+\r
+ if o.chb.AllowGrayed then\r
+ begin\r
+ if (o.chb.State = cbGrayed) then Continue\r
+ end\r
+ else if not(o.chb.Checked) then Continue;\r
+ \r
if (Result <> '') then\r
Result := Result + ',';\r
Result := Result + o.name;\r
- if (o.edit = nil) then Continue;\r
+\r
+ if (o.edit = nil) then\r
+ begin\r
+ if o.chb.Checked then\r
+ Result := Result + '=1'\r
+ else\r
+ Result := Result + '=0';\r
+ Continue;\r
+ end;\r
s := GetStrProp(o.edit, 'Text');\r
if (Pos(' ', s) <> 0) or (Pos('"', s) <> 0) or (Pos(',', s) <> 0) then\r
s := SysUtils.AnsiQuotedStr(s, '"');\r